<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="format-detection" content="telephone=no">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<title>拼字游戏</title>
	<link rel="stylesheet" type="text/css" href="css/base.css">
	<link rel="stylesheet" type="text/css" href="css/index.css" />
	<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
	<script src="js/rem.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
	<div class="bg"></div>
	<div class="my">
		<img src="./image/my-icon.png" alt="">
	</div>
	<div class="banner">
		<img src="./image/index-banner.png" alt="">
	</div>
	<div class="explain"></div>
	<div class="continue">开始游戏</div>
	<div class="partake">已有
		<span>10</span> 人参与挑战</div>
	<div class="partake">您今天还有
		<span class='challengenum'>X</span> 次挑战机会</div>
	<div class="rule">
		<div class="rule-font">游戏规则</div>
		<div class="rule-c">
		</div>
	</div>
	<div class="pop">
		<div class="pop-t"></div>
		<div class="pop-c">
			<img src="./image/share.png" alt="">
		</div>
	</div>
</body>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jweixin-1.0.0.js"></script>
<script src="js/mui.min.js"></script>
<script src="libs/base.js"></script>
<script>
</script>
<script type="text/javascript">
	isUserInfo(function () {
		$('.my').click(function () {
			location.href = 'my.html';
		})
		// 总抽奖次数
		var challengenum;
		// 剩余抽奖次数
		var challengednum;
		var activeId;
		ajax.request({
			params: {
				action: 'active',
				wxopenid: getUserInfo().ResultData.wxopenid
			},
			callback: function (res) {
				challengenum = res.challengenum;
				challengednum = res.challengednum;
				activeId = res.id;
				$('.explain').html(res.remark);
				$('.rule-c').html(res.description);
				$('.partake>span.challengenum').html(challengenum - challengednum);
			}
		})
		$('.continue').click(function () {
			ajax.request({
				params: {
					action: 'active',
					wxopenid: getUserInfo().ResultData.wxopenid
				},
				callback: function (res) {
					var challengenumm = res.challengenum;
					var challengednumm = res.challengednum;
					if (challengenumm - challengednumm > 0) {
						location.href = 'game.html';
					} else {
						var btnArray = ['取消', '分享'];
						mui.confirm('今日挑战次数已用完，分享可获得1次挑战机会', '提示', btnArray, function (e) {
							if (e.index == 1) {
								$('.pop').fadeIn();
							} else {
								mui.toast('分享失败');
							}
						})
					}
				}
			})
		})
		$('.pop').click(function () {
			$('.pop').fadeOut();
		})



		wxFunction(function () {
			wx.ready(function () {
				wx.onMenuShareTimeline({
					title: '拼字赢好礼', // 分享标题
					link: baseurl + 'index.html', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: baseurl + 'image/index-banner.png', // 分享图标
					success: function () {
						changechallnum(activeId);
					}
				})
				wx.onMenuShareAppMessage({
					title: '拼字赢好礼', // 分享标题
					desc: '拼字赢好礼', // 分享描述
					link: baseurl + 'index.html', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: baseurl + 'image/index-banner.png', // 分享图标
					success: function () {
						changechallnum(activeId);
					}
				});
			});
		})
	})
</script>

</html>